package com.zyc.controller;

import com.zyc.commonUtils.R;
import com.zyc.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author zyc
 * @create 2022-02-15-16:32
 */
@RestController
@RequestMapping("/eduoss/file")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传头像
     * @param file
     * @return
     */
    @PostMapping
    public R upLoadOssFile(MultipartFile file) {
        String url = ossService.upLoadFileAvatar(file);
        return R.ok().data("url",url);
    }
}
